package com.cqwshzj.config;/**
 * @Description:
 * @Auther: Huang Zhijin
 * @Version: 1.0.0
 * @Date: 2021/4/7 13:49
 */

import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *
 * 〈〉
 *
 * @author Huang Zhijin
 * @create 2021/4/7
 * @since 1.0.0
 */
@Configuration
@ConditionalOnExpression("'${regCenter.serverList}'.length() >0")
public class RegistryCenterConfig {

	@Bean(initMethod = "init")
	public ZookeeperRegistryCenter registryCenter(
			@Value("${regCenter.serverList}") String serverList,
			@Value("${regCenter.namespace}") String namespace ){
		return new ZookeeperRegistryCenter( new ZookeeperConfiguration(serverList, namespace) );
	}


/*	@Bean(initMethod = "init")
	public ZookeeperRegistryCenter registryCenter(){
		String serverList= "localhost:6181";
		String namespace = "hzj";
		return new ZookeeperRegistryCenter( new ZookeeperConfiguration(serverList, namespace) );
	}*/

}
